/**
 * @authors tanqichao
 * @date    2017-03-21 13:59:27
 * @module  账户余额
 */
import React, { Component } from 'react';
import Styles from './indexPage.less';
import { Row, Col, Button } from 'antd';
import { connect } from 'dva';
import classNames from 'classnames';
import { AccessControl } from '../../utils/common';
// import '../plugin/iconfont/iconfont'
// classNames('foo', 'bar'); // => 'foo bar'

class Consulting extends Component {
	render () {
		const balance = this.props.balance;
		const permissionList = this.props.permissions;
		const renderNumber = () => {
			if (balance) {
				const balanceStr = balance.toString().split('');
				const Options = balanceStr.map((item,index) => {
					let cls = null;
					if (item === '.') {
						cls = classNames(Styles.money, Styles.iconfont, Styles.iconDian);
					} else {
						cls = classNames(Styles.money, Styles.iconfont, Styles[`iconIconTest${item}`]);
					}
						return <i key={index} className={cls}></i>
					}
	      );
	      return Options;
			}
		}
 		return (
			<span>
			{
				AccessControl(permissionList, 'dsp_fund_flow') ?
					<div className={Styles.balance}>
						<span className={Styles.title}>我的账户余额：</span>
						<span>{renderNumber()}</span>
						<Button ghost type="primary" className={Styles.balanceBtn}>
							<a href="http://wpa.qq.com/msgrd?v=3&uin=1346847911&site=qq&menu=yes" target="_blank">充值咨询</a>
						</Button>
					</div> : null
			}
			</span>
		)
	}
};

// export default Consulting;
export default connect((state) => {
  const { permissions } = state.indexPage
	// console.log(permissions)
  return {
    permissions
  }
})(Consulting);
